
/**
 * selector（斯莱克特）：选择器
 */
import { useSelector, useDispatch } from 'react-redux'
import { updateCount } from '../reduxStore/modules/tongbuData';

function A() {
  // 通过 useSelector钩子函数将store数据映射到组件中
  const { count } = useSelector(state => state.tongbuReducer)
  const dispatch = useDispatch();

  function hanldeBtn() {
    // 1. 生成action对象
    const action = updateCount(count+1);
    dispatch(action)
  }

  return (
    <div>
      <button onClick={ hanldeBtn }>同步toolkit--{count}</button>
    </div>
  )
}

export default A;